home *** CD-ROM | disk | FTP | other *** search
- Path: atglab.bls.com!Alun.Champion
- From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
- Newsgroups: comp.lang.c++
- Subject: Re: Asynchronous I/O, Re: cin.get() function challenge
- Date: 31 Jan 1996 22:02:32 GMT
- Organization: Computer People Inc.
- Message-ID: <ALUN.CHAMPION.96Jan31170232@g7240065.bridge.bst.bls.com>
- References: <4eavds$d0u@news.cencom.net>
- <ALUN.CHAMPION.96Jan29143951@g7240065.bridge.bst.bls.com>
- <bredelin-3101961313580001@apm-b325-8.ucsd.edu>
- NNTP-Posting-Host: bstfirewall.bst.bls.com
- In-reply-to: bredelin@sdcc13.ucsd.edu's message of 31 Jan 1996 21:14:00 GMT
-
- In article <bredelin-3101961313580001@apm-b325-8.ucsd.edu> bredelin@sdcc13.ucsd.edu (Benjamin Redelings) writes:
-
- : I've been trying to find a read routine that doesn't block (i.e. wait to
- : return) until a carriage return is entered. My program needs to
- : continuously process data, stopping periodically to process any input that
- : may have enterred the keyboard buffers since that last time it checked.
-
- : A. On method would be the check the size of the keyboard buffer, called
- : cin.get() only if a complete line is present. That would be optimal, and
- : would not involve any blocking. However, whoever wrote iostream went to
- : great lengths to make sure that checking the size of cin's buffer is
- : really nasty. I think I would have to write my own io library just to
- : check the size of the keyboard buffer!
-
- Unfortunately this wont work, cin's buffer in no way reflects how many
- characters there are to read in the keyboard buffer.
-
- : B. The other method would be to read all the input that is available, and
- : process if necessary. However, if there is NO input, cin.get() WAITS for
- : a carriage return, which means that the user must press return every time
- : cin.get() is called to make the program keep processing. That is
- : ridiculous.
-
- : However, Alun Champion says
- : >
- : > It is the host environment which line buffers.
- : > In the UNIX environment you can use ioctl() calls to change the
- : > buffering characteristics of the terminal attached to cin, in other
- : > environments there may or may not be a mechanism by which you can
- : > inform the environment that line buffering is not to be performed.
- : > This is very dependent on the host environment, try a programmers
- : > newsgroup for the environment you are interested in.
- : >
-
- : Does anyone have more information? How does one go about this, and what
- : might cin.get() be expected to return if it underflowed?
-
- I would advise following my advice and try asking the question in the
- programmers newsgroup for the environment you are interested in.
- I can answer this question for the UNIX environment (though I don't peruse
- the Unix newsgroups (too much noise ;')), mail me if this is what you
- need.
-
- Regards
-
- -A.
-
- --
- | A.Champion |
-